#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    number=new QLCDNumber(this);
    number->display(10);
    number->setGeometry(200,100,300,200);

    connect(&thread,&Thread::notify,this,&Widget::handler);
    //启动线程
    thread.start();
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handler()
{
    //让主线程去修改显示器显示的数字
    int value=number->intValue();
    if(value<=0)
    {
        return;
    }
    value--;
    //更新
    number->display(value);
}

